package com.ruoyi.mqtt.service;

import com.ruoyi.mqtt.config.MQTTClientUtils;
import com.ruoyi.mqtt.dto.MqMessage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class MQTTService {
    @Resource
    private MQTTClientUtils mqttClientUtils;

    /**
     * 向主题发送消息
     * @param topicName
     * @param message
     */
    public void sendMessage(String topicName, MqMessage message){
        mqttClientUtils.publish(topicName, message);
    }

    /**
     * 向主题发送消息
     * @param topicName 主题名称
     * @param qos qos
     * @param message 具体消息
     */
    public void sendMessage(String topicName,int qos, String message){
        mqttClientUtils.publish(topicName, qos, message);
    }
}
